#!/bin/sh

set -e

# 环境变量设置
source ~/.vis_profile

device_id=$1
rtsp_url=$2
width=$3
height=$4

mkdir -p ${VIS_FILE_ROOT_PATH}/thumbnail/bak
rm -rf ${VIS_FILE_ROOT_PATH}/thumbnail/bak/${device_id}.png

${VIS_ROOT_PATH}/manager/etc/ffmpeg/bin/ffmpeg -v 0 -i ${rtsp_url} -y -f image2 -ss 0.001 -frames:v 1 -s ${width}x${height} ${VIS_FILE_ROOT_PATH}/thumbnail/bak/${device_id}.png

if [ -f ${VIS_FILE_ROOT_PATH}/thumbnail/bak/${device_id}.png ]; then
    mv ${VIS_FILE_ROOT_PATH}/thumbnail/bak/${device_id}.png ${VIS_FILE_ROOT_PATH}/thumbnail/${device_id}.png
fi

echo 0
